<!DOCTYPE html>
<html>
<head>
<div th:include="base-libs :: base-libs" />
<title>我的签约患者</title>

<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">

<style>
	.laydate-icon{
		width:87% !important;
		padding-left: 5px;
		line-height: 28px;
		background-color: #fff;
		height: 28px;
		border: 1px solid #B6B6B6;
		border-radius: 5px;
	}
	.spanBtn{
		font-weight: bold;
    	color: blue;
    	cursor:pointer;
	}
</style>
<!--[if IE 8.0]>
<style>
	#SHZT{
		position:relative;
		top:3px;
		line-height:30px;
	}
</style>
<![endif]-->
<script th:inline="javascript">
    /**读取request中的初始化数据*/
    var requestData = [[${requestData}]];
</script>
	<script>

        var initKsdm = [{KSDM : "" , KSMC : "全部"}];
        var initYsxm = [{YSGH : "" , XM : "全部"}];
        $(function(){
            $(this).registerManagerPage();
            initView();
            initData();
            $("#btnQuery").trigger("click");
        })

        function initData(){
            if(!requestData["isManager"]){
                $("#combogridYljg").combogrid("grid").datagrid("loadData", [requestData]);
                $("#combogridYljg").combogrid("setValue", requestData);
                initYsAndKs(requestData);
            }
        }

        function initView() {
            //回车查询
            enterToQuery(btnQueryHandler);

            $('#YJKSDM').combobox({
                height: 30,
                width: 250,
                valueField:'KSDM',
                textField:'KSMC',
                mode : "local",
                data : initKsdm,
                inputCode: 'inputCode', //拼音码
                filter: function(q, row){
                    var opts = $(this).combobox('options');
                    return row[opts.textField].indexOf(q) == 0;
                }
            });
            var readonly = !requestData["isManager"];
            $("#combogridYljg").combogrid({
                height: 30
                ,width: 250
                ,panelWidth: 500
                ,singleSelect: true
                ,pagination: true
                ,idField: 'YLJGDM'
                ,textField: 'YLJGMC'
                ,mode: "remote"
                ,readonly: readonly
                ,hasDownArrow: !readonly
                ,url: "/console/yljgxx/queryPageSummary.service"
                ,delay: 1000
                ,reversed: false
                ,columns:[[
                    {
                        field:'YLJGMC'
                        ,title:'医疗机构名称'
                        ,width:240,
						formatter:function (value) {
							return '<span title="'+ value +'">'+value+'</span>'
                    	}
                    }
                    ,{
                        field:'XZQHMC'
                        ,title:'行政区划'
                        ,width:80
                    }
                    ,{
                        field:'WSJGLBMC'
                        ,title:'机构类别'
                        ,width:80
                    }
                    ,{
                        field:'YYDJMC'
                        ,title:'机构等级'
                        ,width:80
                    }
                ]]
                ,onBeforeLoad: function(queryParams) {
                    var url = $(this).datagrid("options")["url"];
					/*URL不等空时再发送请求*/
                    if (!readonly) {
                        queryParams["pageSize"] = queryParams["rows"];
                        queryParams["pageNumber"] = queryParams["page"];
                        queryParams["YLJGMC"] = queryParams["q"];
                        var result = [];
                        $("#YJKSDM").combobox("clear");
                        $("#YJKSDM").combobox("loadData",initKsdm);
                        return true;
                    }else{
                        return false;
                    }
                },
                onClickRow : function(rowIndex, rowData){
                    var queryParams = $.extend({}, rowData);
                    initYsAndKs(queryParams);
                },
                onLoadSuccess : function(data){

                }
            });

            $("#qyhzTable").datagrid({
                idField : "YJBH",
                striped : true,
                clickToSelect: true,
                fitColumns: true,
                fit:true,
                scrollbarSize:15,
                singleSelect: true,
                columns : [[
// 						{field : "xz",checkbox:true},
                    {field : "YLJGMC",title : "医院名称",width:180, align:'center', formatter : function(value){
                        return '<span title="'+value+'">'+value+'</span>';
                    }},
                    {field : "KSMC",title : "科室名称",width:60, align:'center',formatter:function(value){
//							var reg = /.{8}$/;
//							return value.replace(reg,'********');
                        return value;
                    }},
                    {field : "XMFLMC",title : "项目分类",width:60, align:'center'},
                    {field : "XMMC",title : "项目名称",width:60, align:'center',formatter:function(value){
                        return value;
                    }},
                    {field : "TWMC",title : "体位",width:60, align:'center',formatter:function(value){
                        return value;
                    }},
                    {field : "YYRQ",title : "预约日期",width:60, align:'center' , formatter: function(value){
                        return value.substring(0,10);
                    }},
                    {field : "YYSJD",title : "时间段",width:70, align:'center',formatter:function(value){
                        return value;
                    }},
                    {field : "SFJJ",title : "是否加检",width:40, align:'center'},
                    {field : "SYKYYS",title : "剩余可预约数",width:60, align:'center'},
                    {field : "YYYS",title : "已预约数",width:60, align:'center'}
                ]],
                pagination : true,
                pageList: [10, 20, 50, 100, 200],
                method : "post",
                onBeforeLoad : function(params) {
                    var YLJGDM = $("#combogridYljg").combobox("getValue");
                    var YJKSDM = $("#YJKSDM").combobox("getValue");
                    params["YLJGDM"] = YLJGDM;
                    params["YJKSDM"] = YJKSDM;
                    getContainerDataByClassName('conditionBox','condition',params);//查询条件
                },
                onClickRow : function(rowIndex, rowData){

                },
                onLoadSuccess: function(data){
// 					alert(JSON.stringify(data))
                },
            });



            //查询开始时间设置
            var startTimeObj = {
                elem: '#YYRQ_START',
                choose: function(datas){
                    endTimeObj.min = datas;
                }
            };
            laydate(startTimeObj);

            //查询结束时间设置
            var endTimeObj = {
                elem: '#YYRQ_END',
                choose: function(datas){
                    startTimeObj.max = datas;
                }
            };
            laydate(endTimeObj);
        }

        /** 初始化医生与一级科室下拉框 */
        function initYsAndKs(params){
            $.QuickRemote.AjaxJson("/console/ksxx/", function(result){
                result = initKsdm.concat(result);
                $("#YJKSDM").combobox("loadData",result);
            }, params);
        }


        /**获取查询表单的值*/
        function getQueryFormValue() {
            var params = {};
            var item = $("#combogridYljg").combogrid("grid").datagrid("getSelected");
            if(item){
                params["YLJGDM"] = item["YLJGDM"];
            }else{
                params["YLJGMC"] = $("#combogridYljg").combogrid("getText");
            }
            //params["KSMC"] = $("#KSMC").val();
            return params;
        }

        /** 查询  */
        function btnQueryHandler(){
            $("#qyhzTable").datagrid({"url":"pageQueryAll.service"});
        }

        /** 导出 */
        function download(){
            var params = getQueryFormValue();
            if(params["YLJGDM"]){
                $("#YLJGDM").attr("name" , "YLJGDM").val(params["YLJGDM"]);
            }
            $("#downloadForm").submit();
        }

	</script>

</head>

<body>
	<div class="easyui-layout" fit="true" border="false">
		<div region="north" style="overflow:hidden;padding:15px 0px;background:#f9f9f9" border="false">
			<form action="queryAllForExcel.service" method="post" enctype="multipart/form-data" id="downloadForm" >
				<table class="form-table" id="conditionBox">
					<tr>
						<td class="td-text">所属医院：</td>
						<td class="td-content">
							<input id="YLJGDM" hidden="hidden" >
							<input id="combogridYljg" />
						</td>
						<td class="td-text">所属科室：</td>
						<td class="td-content">
							<select id="YJKSDM" name="YJKSDM" class="form-control condition easyui-combobox" style="width: 100%;">
								<option value="">全部</option>
							</select>
						</td>
						<td class="td-text">项目分类：</td>
						<td class="td-content">
							<select name="XMFLDM" id="XMFLDM" cacheTable="TB_ZY_JCXMFL" class="form-control condition" style="width: 100%;">
								<option value="">全部</option>
							</select>
						</td>
						<td class="td-text" style="width:175px;text-align:center">
							<button id="btnQuery" class="btn btn-info" type="button" onclick="btnQueryHandler()">查询</button>
							<button type="button" onclick="download()">导出</button>
						</td>
					</tr>
					<tr class="activeQuery">
						<td class="td-text">具体项目：</td>
						<td class="td-content">
							<select id="XMDM" name="XMDM" cacheTable="TB_ZY_JCXM" class="form-control condition" style="width: 97%;">
								<option value="">全部</option>
							</select>
						</td>
						<td class="td-text">预约日期：</td>
						<td class="td-content">
							<input name="YYRQ_START" id="YYRQ_START" class="laydate-icon condition" />
						</td>
						<td class="td-text">至：</td>
						<td class="td-content">
							<input name="YYRQ_END" id="YYRQ_END" class="laydate-icon condition" />
						</td>
						<td class="td-text"></td>
					</tr>
				</table>
			</form>
			<!--<div style="margin-top:10px;">
				&nbsp;&nbsp;&nbsp;&nbsp;
				<button type="button" onclick="">门诊预约</button>
				<button type="button" onclick="forwardSzxt('mz')">门诊转诊</button>
				<button type="button" onclick="forwardSzxt('zy')">住院转诊</button>
			</div>-->
		</div>
		<div region="center" border="false">
			<table id="qyhzTable" border="false"></table>
		</div>
	</div>
	
</body>
</html>
